import request from '@/utils/request'

// 查询智能排课任务列表
export function listScheduleTask(query) {
  return request({
    url: '/jwgl/schedule/task/list',
    method: 'get',
    params: query
  })
}

// 查询智能排课任务详细
export function getScheduleTask(id) {
  return request({
    url: '/jwgl/schedule/task/' + id,
    method: 'get'
  })
}

// 新增智能排课任务
export function addScheduleTask(data) {
  return request({
    url: '/jwgl/schedule/task',
    method: 'post',
    data: data
  })
}

// 修改智能排课任务
export function updateScheduleTask(data) {
  return request({
    url: '/jwgl/schedule/task',
    method: 'put',
    data: data
  })
}

// 删除智能排课任务
export function delScheduleTask(id) {
  return request({
    url: '/jwgl/schedule/task/' + id,
    method: 'delete'
  })
}

// 创建排课任务
export function createScheduleTask(data) {
  return request({
    url: '/jwgl/schedule/task/create',
    method: 'post',
    data: data
  })
}

// 启动排课任务
export function startScheduleTask(taskId) {
  return request({
    url: '/jwgl/schedule/task/start/' + taskId,
    method: 'post'
  })
}

// 停止排课任务
export function stopScheduleTask(taskId) {
  return request({
    url: '/jwgl/schedule/task/stop/' + taskId,
    method: 'post'
  })
}

// 获取任务状态
export function getTaskStatus(taskId) {
  return request({
    url: '/jwgl/schedule/task/status/' + taskId,
    method: 'get'
  })
}

// 根据学期查询任务列表
export function getTasksBySemester(semester) {
  return request({
    url: '/jwgl/schedule/task/semester/' + semester,
    method: 'get'
  })
}

// 查询正在执行的任务
export function getRunningTasks() {
  return request({
    url: '/jwgl/schedule/task/running',
    method: 'get'
  })
}

// 获取任务执行历史
export function getTaskHistory(params) {
  return request({
    url: '/jwgl/schedule/task/history',
    method: 'get',
    params: params
  })
}

// 更新任务进度
export function updateTaskProgress(taskId, progress) {
  return request({
    url: '/jwgl/schedule/task/progress/' + taskId,
    method: 'post',
    params: { progress: progress }
  })
}

// 完成任务
export function completeTask(taskId, resultData) {
  return request({
    url: '/jwgl/schedule/task/complete/' + taskId,
    method: 'post',
    data: resultData
  })
}

// 标记任务失败
export function failTask(taskId, errorMessage) {
  return request({
    url: '/jwgl/schedule/task/fail/' + taskId,
    method: 'post',
    params: { errorMessage: errorMessage }
  })
}

// 导出智能排课任务
export function exportScheduleTask(query) {
  return request({
    url: '/jwgl/schedule/task/export',
    method: 'post',
    data: query
  })
}